//  对运算过程抽象 只需要关注目标



// map
const map = (array, fn) => {
    let arr = []
    for(let value of array) {
        arr.push(fn(value))
    }
    return arr
}

// let ar = [1,2,3,4]

// ar = map(ar, item => item * item)

// console.log(ar)

// every
const every = (array ,fn) => {
    let reslut = true
    for(let value of array) {
        reslut = fn(value)
        if(!reslut) {
            break
        }
    }
    return reslut
}
// let arr = [9,12,14]

// let r = every(arr, v => v > 10)
// console.log(r)

// some
const some = (array, fn) => {
    let reslut = false
    for(let value of array) {
        reslut = fn(value)
        if(reslut) {
            break
        }
    }
    return reslut
}

let arr = [1,3,5,7]
let r = some(arr, v => v%2 === 0)
console.log(r)


